package com.aistar.mapper;

import com.aistar.model.entity.Employee;
import com.aistar.model.entity.EmployeeCollection;
import com.aistar.model.entity.Intern;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface EmployeeCollectionMapper {
    //插入数据
    @Insert("insert into employee_collection values(#{id},#{employeeId},#{recruitmentId},#{recruitmentName})")
    int save(EmployeeCollection employeeCollection);

    //查找数据表全部数据
    @Select("select * from employee_collection")
    List<EmployeeCollection> findAll();

    //通过职位id查找数据
    @Select("select * from employee_collection where recruitment_id=#{rid} and employee_id=#{eid}")
    EmployeeCollection findByRecruitmentId(Integer rid, Integer eid);

    //根据求职者id获取职位id数据
    @Select("select recruitment_id from employee_collection where employee_id=#{id}")
    List<Integer> findByEmployeeId(Integer id);

    //通过职位id查找数据
    @Select("select count(*) from employee_collection where recruitment_id=#{rid} and employee_id=#{eid}")
    int findByCountRecruitmentId(Integer rid, Integer eid);

    //根据求职者id和职位id删除数据
    @Delete("delete from employee_collection where recruitment_id=#{rid} and employee_id=#{eid}")
    int delByRidAndEid(Integer rid,Integer eid);

    @Select("select * from employee_collection where id=#{id}")
    EmployeeCollection findById(Integer id);

    @Select("select * from employee_collection where employee_id=#{id}")
    List<Integer> findAllByEmployeeId(Integer id);

    @Delete("delete from employee_collection where id=#{id}")
    Integer deleteById(Integer id);

    @Delete("delete from employee_collection where employee_id=#{employeeId} and recruitment_id=#{recruitmentId}")
    Integer deleteByEidAndRid(Integer employeeId,Integer recruitmentId);
}
